#include "globals.h"
#include "key.h"

void Delay(uint32_t nCount)
{
	vTaskDelay(nCount);
}

void _delay(volatile int i)
{
	while(i!=0)
	{
		i--;
		i++;
		i--;
		i++;
		i--;
	}
}

void HAL_Delay(__IO uint32_t Delay)
{
	vTaskDelay(Delay);
}

uint16_t getCRC(uint8_t*data_value, uint16_t data_length){
	int i;
	unsigned int crc_value=0xffff;
	while(data_length--)
	{
		crc_value^=*data_value++;
		for(i=0;i<8;i++)
		{
			if(crc_value&0x0001)crc_value=(crc_value>>1)^0xa001;
			else crc_value=crc_value>>1;
		}
	}
	return(crc_value);
}

void Error_Handler(void)
{
	BuzzerON_Error();
	while(1)
	{
		LED_RED_0; LED_GREEN_0;
		_delay(1000);
		LED_RED_1; LED_GREEN_1;
		_delay(1000);
	}
}
